﻿using PRO.Common;
using PRO.Config;
using PRO.Entity;
using PRO.Product;
using PRO.Public;
using PRO.User;
using System;
using System.Collections.Generic;
using System.Data;
using System.Linq;
using System.Web;
using System.Web.UI;
using System.Web.UI.WebControls;

namespace web.Products
{
    public partial class classify : PageBase,ICallbackEventHandler
    {
        protected bool error = false;
        protected int id = CVGRequest.GetQueryString("id").DEC_Decode(BaseConfigs.DEC_KEY).ToInt(0);
        protected void Page_Load(object sender, EventArgs e)
        {
            if (!IsPostBack)
                ClientScript.GetCallbackEventReference(this, "", "", "");
            if (id == 0)
            {
                error = true;
                ErrorControl.Msg = "非常抱歉，您访问的页面不存在！";
            }
            else
                Bind();
        }
        private void Bind()
        {
            int counts = 0;
            int pages = 0;
            this.Pager1.PageSize = 12;
            DataTable dt = PublicLib.CutPage("Pro_Product", "id", "edittime desc", this.Pager1.PageIndex, this.Pager1.PageSize, "id,cid,title,des,icon,price,edittime", "(cid=" + id + " and show=1)", "", out pages, out counts);
            this.Pager1.RecordCount = counts;
            this.Repeater1.DataSource = dt;
            this.Repeater1.DataBind();
        }
        private string CallbackResult = null;
        public string GetCallbackResult() { return CallbackResult; }
        public void RaiseCallbackEvent(string code)
        {
            if (ShopCart.ADD(code))
                CallbackResult = "1";
            else
                CallbackResult = "0";
        }
    }
}